package ClienteCompraProduto;

import org.nakedobjects.extended.Cardinality;
import org.nakedobjects.extended.Entity;
import org.nakedobjects.extended.RelationshipObject;
import org.nakedobjects.extended.Way;
import org.nakedobjects.object.AbstractNakedObject;
import org.nakedobjects.object.Title;
import org.nakedobjects.object.collection.ExtendedInternalCollection;
import org.nakedobjects.object.value.TextString;

@Entity
public class Cliente extends AbstractNakedObject {
	
	private TextString nome = new TextString();
	private TextString cep = new TextString(); 
	
	@RelationshipObject(
			cardinality=Cardinality.ManyToMany, 
			compositeClass=NotaFiscal.class, 
			compositeFieldName="notasfiscais",
			compositeFieldRelatedName="produto", 
			fieldRelatedName="cliente",
			relatedWith=Produto.class,
			way=Way.TwoWay)
	private final ExtendedInternalCollection notasfiscais = new ExtendedInternalCollection(
			"Notasfiscais", NotaFiscal.class, this);
	
	public ExtendedInternalCollection getNotasfiscais() {
		return notasfiscais;
	}
	 
	public TextString getCep() {
		return cep;
	}

	public TextString getNome() {
		return nome;
	}

	@Override
	public Title title() {
		return this.getNome().title();
	}
}